function number(data, size = 2) {
    if (data instanceof Uint8Array) {
        let arr = [];
        for (let byte of data) {
            arr.push(`0x${byte.toString(16).padStart(2, '0')}`);
        }
        return `[${arr.join(', ')}]`;
    }
    if (typeof data === 'number') {
        return `0x${data.toString(16).padStart(size, '0')} = ${data.toString()}`;
    }
};

function char(data) {
    if (data instanceof Uint8Array) {
        let arr = [];
        for (let byte of data) {
            arr.push(`'${String.fromCharCode(byte)}'`);
        }
        return `[${arr.join(', ')}]`;
    }
    if (typeof data === 'number') {
        return `'${String.fromCharCode(data)}'`;
    }
    return `'${data}'`;
}

function str(data) {
    return data;
}

function varint(data) {
    return `0x${data.toString(16).padStart(2, '0')}`;
}

function hash(data) {
    if (data instanceof Uint8Array) {
        let arr = [];
        for (let byte of data) {
            arr.push(`${byte.toString(16).padStart(2, '0')}`);
        }
        return `${arr.join('')}`;
    }
    return ""
}

export default {
    number,
    char,
    str,
    varint,
    hash,
};